﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;

namespace MvcEmrRazor.Helpers
{
    public static class ImageActionLinkHelper
    {

        public static string ImageActionLink(this AjaxHelper helper, string imageUrl, string altText, string actionName, object routeValues, AjaxOptions ajaxOptions)
        {
            var builder = new TagBuilder("img");
            builder.MergeAttribute("src", imageUrl);
            builder.MergeAttribute("alt", altText);
            //string s = helper.ActionLink(builder.ToString(TagRenderMode.SelfClosing), actionName, routeValues, ajaxOptions).ToString();
            //return s;
            //var link = helper.ActionLink("[replaceme]", actionName, routeValues, ajaxOptions);
            //return link.Replace("[replaceme]", builder.ToString(TagRenderMode.SelfClosing));
            var link = helper.ActionLink("[replaceme]", actionName, routeValues, ajaxOptions);
            string t = link.ToString();
            t = t.Replace("[replaceme]", builder.ToString(TagRenderMode.SelfClosing));
            return t;
        }

    }
}